import gradio as gr
import pandas as pd

def select_data(state:gr.State, evt: gr.SelectData):
    state = evt.index[0]
    return f"You selected cell at row {evt.index[0]}, column {evt.index[1]} with value {evt.value}"

df = pd.DataFrame({
    "col1": [1, 2, 3],
    "col2": [4, 5, 6],
    "col3": [7, 8, 9]
})

with gr.Blocks() as demo:
    state = gr.State()
    dataframe = gr.DataFrame(df, interactive=True)

    text_output = gr.Textbox()
    dataframe.select(select_data, state, text_output)

demo.launch()